import React from 'react';
import {connect} from 'dva';
import withRouter from 'umi/withRouter';
import {Layout} from '../../components';
import {Table,Button} from 'antd';
const {Tab} = Layout;


const columns = [{
  title: '状态',
  dataIndex: 'statusLink',
  key: 'statusLink',
  tag: ['status'],
  render:(item, record)=>{
    return item.status
  }
}, {
  title: '信息',
  dataIndex: 'inforLink',
  key: 'inforLink',
  tag: ['company','order','price'],
  render:(item, record)=>{
    let str=(
      <div>
        {item.company} / 订单号：{item.order} / <span className="red">{item.price}元</span>
      </div>
    )      
    return str;
  }
}, {
  title: '时间',
  dataIndex: 'timeLink',
  key: 'timeLink',
  tag: ['time'],
  render:(item, record)=>{
    return item.time
  }
}, {
  title: 'Action',
  key:'Action',
  render: (item, record) => (
    <Button type="primary" ghost>立即处理</Button>
  ),
}];

function DealList({children, dealList , dispatch, location, history}) {
  const {list}=dealList
  list.map((item,index)=>{
    item.key=index
    columns.map((itemInner,indexInner)=>{
      if(itemInner.tag){
        item[itemInner.dataIndex]={};
        itemInner.tag.map((keyItem,keyIndex)=>{
          item[itemInner.dataIndex][keyItem]=item[keyItem]
        })
      }
    })
  })
  
  const tabProps={
    tabContent:[{
      num:20,
      title:'全部',
      content:<Table dataSource={list} columns={columns} showHeader={false} pagination={ {showQuickJumper:true,defaultCurrent:1 ,total:500,showTotal:(total, range) =><div style={{position:'absolute',left:0}}>显示 {range[0]} 到 {range[1]} 项 ，共 {total} 项</div>,
}}/>
    },{
      num:20,
      title:'待确认订单',
      content:<Table dataSource={list} columns={columns} showHeader={false}  pagination={ {showQuickJumper:true,defaultCurrent:1 ,total:500,showTotal:(total, range) =><div style={{position:'absolute',left:0}}>显示 {range[0]} 到 {range[1]} 项 ，共 {total} 项</div>,
}}/>
  },{
    num:20,
    title:'待发货订单',
    content: <Table dataSource={list} columns={columns} showHeader={false}  pagination={ {showQuickJumper:true,defaultCurrent:1 ,total:500,showTotal:(total, range) =><div style={{position:'absolute',left:0}}>显示 {range[0]} 到 {range[1]} 项 ，共 {total} 项</div>,
}}/>
  },{
    num:20,
    title:'待确认实发',
    content: <Table dataSource={list} columns={columns} showHeader={false}  pagination={ {showQuickJumper:true,defaultCurrent:1 ,total:500,showTotal:(total, range) =><div style={{position:'absolute',left:0}}>显示 {range[0]} 到 {range[1]} 项 ，共 {total} 项</div>,
}}/>
  }]
}
return(
      <div  className="padding10 white">
        <Tab {...tabProps}/>
      </div>
  )
}



export default withRouter(connect(({dealList }) => ({dealList }))(DealList));
